﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U;
using webapp4U.BOL;

namespace webapp4U.UI
{
    public partial class Article : System.Web.UI.Page //BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Globals.GetStringFromQueryString("Action") == "Edit" && !Page.IsPostBack)
            {
                int ChatlieuID = Globals.GetIntFromQueryString("ChatlieuID");
                Load_ChatlieuByID(ChatlieuID);
            }
        }

     
        private void Load_ChatlieuByID(int ChatlieuID)
        {
            webapp4U.BOL.Chatlieu obj = webapp4U.BOL.Chatlieu.GetChatlieuByID(ChatlieuID);
            txtTitle.Text = obj.Title;
            txtTitle_en.Text = obj.Title_en;
            txtOrder.Text = obj.DisplayOrder.ToString();
        }

        protected void btSave_Click(object sender, EventArgs e)
        {
            Chatlieu obj = new Chatlieu();
            obj.Title = txtTitle.Text;
            obj.Title_en = txtTitle_en.Text;
            obj.DisplayOrder = Globals.ConvertToInt32(txtOrder.Text);

            if (Globals.GetStringFromQueryString("Action") == "Edit")
            {
                obj.ChatlieuID = Globals.GetIntFromQueryString("ChatlieuID");
                webapp4U.BOL.Chatlieu.Update(obj);
            }
            else
            {
                webapp4U.BOL.Chatlieu.Insert(obj);
            }

            Response.Redirect(Globals.ApplicationPath + "WebMaster/Chatlieu/");
        }

      
    
    }
}